<template>
  <div>
    <router-link :to="'/dish/' + did" class="dish-box">
      <!-- 预览图片 -->
      <!-- <img :src="baseURL + cover[0]" alt="" class="thumb" /> -->
      <van-image
        width="100%"
        height="12rem"
        fit="fill"
        :src="cover[0]"
      />
      <div class="title-box">
        <!-- 菜品名称 -->
        <span class="dish-name">{{ dishName }}</span>
        <div class="label-box">
          <!-- 标签 -->
          <van-tag
            class="label"
            size="medium"
            round
            type="success"
            v-for="(item, i) in labels"
            :key="i"
          >
            {{ labels[i].labelName }}
          </van-tag>
        </div>
        <!-- 价格 -->
        <span class="price"
          ><span style="font-size: 14px">￥</span>{{ price }}</span
        >
      </div>
    </router-link>
  </div>
</template>

<script>
// import request from "@/utils/request";

export default {
  name: "DishInfo",
  data() {
    return {
      // baseURL: request.defaults.baseURL,
    };
  },
  // 自定义属性
  props: {
    // 菜品id
    did: {
      type: String,
      default: "",
    },
    // 名字
    dishName: {
      type: String,
      default: "",
    },
    // 价格
    price: {
      type: Number,
      default: 0.0,
    },
    // 封面的信息对象
    cover: {
      require: false,
      type: Array,
      // 通过 default 函数，返回 cover 属性的默认值
      default: function () {
        // 这个 return 的对象就是 cover 属性的默认值
        return [];
      },
    },
    // 标签
    labels: {
      type: Array,
      default: function () {
        return [];
      },
    },
  },
};
</script>

<style lang="less" scoped>
a {
  text-decoration: none;
}
.dish-box {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  height: 220px;
  background-color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  .title-box {
    display: flex;
    width: 100%;
    padding: 10px;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-start;
    .dish-name {
      font-size: 18px;
      color: #222226;
    }
    .label-box {
      display: flex;
      flex-direction: row;
      /deep/ .label {
        margin-right: 3px;
      }
    }
    .price {
      font-size: 22px;
      color: #fe2c24;
      font-weight: 700;
    }
  }
}
</style>